package com.hunter.hmi;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

/**
 * @Project:iwms
 * @Description: 透明界面
 * @Author: Mr.Hunter
 * @Date:2022/6/15/14:10
 */
public class TransparentHmi extends JFrame {
    private int x;
    private int y;

    public void dome(){

        JFrame jf = new JFrame();
        jf.setLayout(new FlowLayout());
        jf.setExtendedState(JFrame.MAXIMIZED_BOTH);
        jf.setUndecorated(true);
        jf.setBackground(new Color(0,0,150,150));
        jf.setVisible(true);

        jf.addMouseListener(new MouseListener() {
            @Override
            public void mouseClicked(MouseEvent e) {

            }
            @Override
            public void mousePressed(MouseEvent e) {
                if(e.getButton()==e.BUTTON3){    // 判断获取的按钮是否为鼠标的右击
                    x = e.getX();    // 获得鼠标点击位置的坐标并发送到标签的文字上
                    y = e.getY();
                    System.out.println(x);
                    System.out.println(y);
                }
            }
            @Override
            public void mouseReleased(MouseEvent e) {
            }
            @Override
            public void mouseEntered(MouseEvent e) {
            }
            @Override
            public void mouseExited(MouseEvent e) {
            }

        });

    }

    public static void main(String[] args) {
        TransparentHmi transparentHmi = new TransparentHmi();
        transparentHmi.dome();

    }

}